package com.abl.lib.common.util;

import org.springframework.util.ResourceUtils;

import java.io.*;


public class FileKit {

    //
    public static File getClassPath(String filePath) {
        try {
            return ResourceUtils.getFile("classpath:" + filePath);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    //
    public static String fileTextContent(File file) {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String content;
            StringBuilder sb = new StringBuilder();
            while ((content = reader.readLine()) != null) {
                sb.append(content);
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
